<template>
    <div class="newsinfo-container">
        <!-- 标题 -->
        <h3 class="title" >{{ newsInfo.title }}</h3>
        <!-- 子标题 -->
        <p class="subtitle">
            <span>发表时间: {{ newsInfo.add_time | dateFormate}}</span>
            <span>点击：{{ newsInfo.click }}次</span>
        </p>

        <!-- 内容 -->
        <div class="content" v-html="newsInfo.content"></div>

        <!-- 评论内容 -->
        <comment :newsInfoId="this.id"></comment>
    </div>
</template>

<script>
    import comment from '../subcomponents/Comment.vue'
    export default {
        name: "NewsInfo",
        data () {
            return {
                id: this.$route.params.id,
                newsInfo: {}
            }
        },
        created() {
            this.getNewsInfo();
        },
        methods: {
            getNewsInfo() {
                this.$http.get('home/NewsInfo.json').then( result => {
                    if (result.body.status === 0) {
                        this.newsInfo = result.body.message[this.id];
                    }
                });
            }
        },
        components: {
            comment
        }
    }
</script>

<style lang="scss" scoped>
    .newsinfo-container {
        padding: 0 4px;
        .title {
            text-align: center;
            font-size: 15px;
        }

        .subtitle {
            color: deepskyblue;
            display: flex;
            justify-content: space-between;
        }




    }
</style>
